/*
 * @Author: wjc
 * @Date: 2025-09-09 17:45:59
 * @LastEditors: wjc
 * @LastEditTime: 2025-10-29 10:00:21
 * @Description:
 */
import type { RouteRecordRaw } from 'vue-router'

import { PAGE_NOT_FOUND_NAME } from '#/utils/settings'
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@nice/utils'

const BasicLayout = () => import('#/layouts/basic/index.vue')
const AuthLayout = () => import('#/layouts/auth/index.vue')

const baseRoutes: RouteRecordRaw[] = [
  /**
   * 根路由
   * 使用基础布局，作为所有页面的父级容器，子级就不必配置BasicLayout。
   * 此路由必须存在，且不应修改
   */
  {
    component: BasicLayout,
    meta: {
      hideInBreadcrumb: true,
      title: 'Root',
    },
    name: 'Root',
    path: '/',
    redirect: DEFAULT_HOME_PATH,
    children: [],
  },
  {
    component: AuthLayout,
    meta: {
      hideInTab: true,
      title: 'Auth',
    },
    name: 'Auth',
    path: '/auth',
    redirect: LOGIN_PATH,
    children: [
      {
        name: 'Login',
        path: 'login',
        component: () => import('#/views/auth/login/index.vue'),
        meta: {
          title: '登录',
        },
      },
    ],
  },
]
const fallbackNotFoundRoute: RouteRecordRaw[] = [
  {
    path: '/401',
    name: '401',
    component: () => import('#/views/err-page/401.vue'),
    meta: {
      hidden: true,
    },
  },
  // 404 page must be placed at the end !!!
  {
    path: '/:path(.*)*',
    name: 'not-found',
    meta: { hidden: true },
    children: [
      {
        path: '/:path(.*)*',
        name: PAGE_NOT_FOUND_NAME,
        component: () => import('#/views/err-page/404.vue'),
        meta: {
          hidden: true,
        },
      },
    ],
  },
]

export { baseRoutes, fallbackNotFoundRoute }
